/*
* @Author: majingyu
* @Date:   2017-05-23 19:52:20
* @Last Modified by:   jingyu.ma
* @Last Modified time: 2017-08-06 21:16:24
*/

import React from 'react';
import { connect } from 'react-redux';
import { Router, Route, Link, hashHistory } from 'react-router';
import 'css/components/orderList.less';
import { changeCommentId } from 'action/commont.js';


class MyOrderList extends React.Component{
    constructor(props){
        super(props); 
    }
    goCommont(id){
       this.props.goCommont(id);
    }
    goToDetail(id){
        this.props.goToDetail(id);
    }
    cacalOrder(id){
        this.props.cacalOrder(id);
    }
    hasMoreList(){
        this.props.getMoreList();
    }
    render(){
        let self = this;
        let orderList = this.props.orderLists.list ? this.props.orderLists.list.map(function(order){
            return(
                <div className="services-list" key={order.orderId}>
                    <div className="order-mess" >
                        <div className="message-title" onClick={()=>self.goToDetail(order.orderId)}>
                            <span className="order-id">{order.orderId}</span>
                            <span className="order-status">{order.status ==1?'已应邀':(order.status ==2?'接受邀请':order.status ==2?'待完成':'已完成')}</span>
                        </div>
                        <div className="order-body">
                            <p className="remark">{order.content}</p>
                            <p className="price">{order.price}元/小时</p>
                            <p className="name">{order.name}</p>
                        </div>
                        <div className="order-footer">
                            <span className="order-time">{order.dtime}</span>
                            <span className="order-btn">
                            {
                                order.type == 5?
                                <a className="btn comment" onClick={()=>{self.goCommont(order.number)}}>去评价</a>:
                                <a className="btn cacal" onClick={()=>{self.cacalOrder()}}>取消订单</a>
                            }
                            </span>
                        </div>  
                    </div> 
                </div>
            );
        }): <div className="list-mess">暂时无数据</div>;
        return(
            <div className="require-list">
                {orderList}
                {
                    ((this.props.orderLists.total/10).toFixed(0)>this.props.orderLists.pageNo && this.props.orderLists.total!=0)?
                    <div className="hasMore" onClick={()=>this.hasMoreList()}>加载更多</div>:''
                }
            </div>
        );
    }
}

export default MyOrderList;